package values.shop
{
import com.adobe.utils.DictionaryUtil;

import flash.utils.Dictionary;

/**
 * ShopConfigValue
 * @author jliang
 *
 */
public class ShopConfigValue
{
    private static var itemList:Dictionary = new Dictionary(true);  /* ShopItemValue */
    
    public function get items():Dictionary
    {
        return itemList;
    }
    
    [Data(type="mapping", 
		   mapping="item", 
		   ref="values.shop.ShopItemValue",
		   way="one_to_more",
		   object="flash.utils.Dictionary",
           key="@key")]
    public function set items(value:Dictionary):void
    {
        if (value && DictionaryUtil.getValues(value).length > 0)
        {
            itemList = value;
        }
    }
    
    public static function getShopItemByKey(key:String):ShopItemValue
    {
        return itemList[key];
    }
    
    private static var groupList:Array;  /* ShopGroupValue */
    
    public function get groups():Array
    {
        return groupList;
    }
    
    [Data(type="mapping", 
		   mapping="group", 
		   ref="values.shop.ShopGroupValue",
		   way="one_to_more")]
    public function set groups(value:Array):void
    {
        if (value && value.length > 0)
        {
            groupList = value;
            groupList.sortOn("index", Array.NUMERIC);
        }
    }
    
    public static function getShopGroupList():Array
    {
        return groupList;
    }
}
}



